package com.sfx.concurrent.demo.concurrent.interrupt;

import lombok.extern.slf4j.Slf4j;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-06-28
 * Time: 10:37
 */
@Slf4j(topic = "c.TestInterrupt")
public class InterruptTest1 {
    //1.使用自带标记位
    private static volatile boolean flg = false;
    public static void main(String[] args) throws InterruptedException {
        new Thread(()->{
            while (!flg) {
                log.debug("test...");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"t1").start();
        Thread.sleep(2000);
        flg = true;
    }
}